Skip to content

feat: add Factory AI (Droid) integration#195

Closed
mrwogu wants to merge 2 commits into
abhigyanpatwari:mainfrom
mrwogu:feat/factory-plugin
Closed

feat: add Factory AI (Droid) integration#195
mrwogu wants to merge 2 commits into
abhigyanpatwari:mainfrom
mrwogu:feat/factory-plugin

Conversation

@mrwogu

@mrwogu mrwogu commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Full Factory AI (Droid) support, mirroring the existing Claude Code integration. Factory AI reads AGENTS.md (the shared standard), so no separate context file is needed.

What's included

Plugin (gitnexus-factory-plugin/):

  • .factory-plugin/ manifest, mcp.json, 7 skills, PostToolUse hook
  • Ready for droid plugin add from the Factory marketplace

Core CLI (gitnexus/):

  • setup.tssetupFactory(), installFactorySkills(), installFactoryHooks() added to npx gitnexus setup
  • ai-context.tsnpx gitnexus analyze now installs skills to .factory/skills/gitnexus/
  • hooks/factory/gitnexus-hook.cjs + post-tool-use.sh (shell equivalent)

Docs (README.md, gitnexus/README.md):

  • Factory AI added to Editor Support table (full support)
  • Manual configuration instructions (droid mcp add)
  • Skills installation path updated (.claude/skills/ + .factory/skills/)

Claude Code vs Factory AI differences addressed

Area Claude Code Factory AI Adaptation
Plugin manifest .claude-plugin/ .factory-plugin/ Renamed
MCP config .mcp.json mcp.json No dot prefix
Hook path variable ${CLAUDE_PLUGIN_ROOT} ${DROID_PLUGIN_ROOT} Updated
Shell tool name Bash Execute Matcher + hook script
Hook event PreToolUse PostToolUse Factory's PreToolUse doesn't support additionalContext
Context file CLAUDE.md AGENTS.md (shared standard) Already generated
Config dir ~/.claude/ ~/.factory/ New setup functions
Skills dir .claude/skills/ .factory/skills/ Parallel installation

Files changed

File Change
gitnexus-factory-plugin/** New — standalone plugin for Factory marketplace
gitnexus/src/cli/setup.ts Added Factory detection, skills, and hooks installation
gitnexus/src/cli/ai-context.ts Added .factory/skills/ installation
gitnexus/hooks/factory/gitnexus-hook.cjs New — PostToolUse hook (Node.js)
gitnexus/hooks/factory/post-tool-use.sh New — PostToolUse hook (shell)
README.md Added Factory AI to Editor Support table + manual config
gitnexus/README.md Added Factory AI manual config
.gitignore Added .factory/settings.local.json, .factory/worktrees/

Test plan

  • Install plugin via droid plugin add and verify it loads
  • Confirm MCP server starts (npx gitnexus mcp)
  • Verify PostToolUse hook fires on Grep/Glob/Execute and augments with graph context
  • Test skills are discoverable and invocable
  • Run npx gitnexus setup and verify Factory AI is detected and configured
  • Run npx gitnexus analyze and verify .factory/skills/ are created
  • TypeScript compiles without errors

@vercel

vercel Bot commented Mar 6, 2026

Copy link
Copy Markdown

@mrwogu is attempting to deploy a commit to the NexusCore Team on Vercel.

A member of the Team first needs to authorize it.

@mrwogu mrwogu force-pushed the feat/factory-plugin branch 4 times, most recently from f56124d to 44c3e71 Compare March 6, 2026 11:02
@mrwogu mrwogu changed the title feat: add Factory AI plugin feat: add Factory AI (Droid) integration Mar 6, 2026
@mrwogu mrwogu force-pushed the feat/factory-plugin branch 5 times, most recently from 6969afb to 2787491 Compare March 6, 2026 15:04

@reversTeam reversTeam left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impressive work, @mrwogu! This is a substantial integration and the PR description is excellent — the Claude Code vs Factory AI comparison table is especially helpful. A few observations:

What looks good:

  • The adaptation table clearly documents every difference between the two platforms and how each is handled.
  • The plugin structure (gitnexus-factory-plugin/) is well-organized with proper manifest, hooks, MCP config, and skills.
  • The hook logic in gitnexus-hook.js is defensive — it checks for the .gitnexus index, validates tool names, and has graceful fallback from direct binary to npx.
  • Skills are comprehensive and well-written with clear workflows and examples.
  • The .gitignore additions for Factory-specific files are correct.

Issues / suggestions:

  1. Hook uses Execute but hooks.json matcher also lists it — The extractPattern function handles Grep, Glob, and Execute. For Execute, it only fires when the command contains rg or grep. This is smart, but the regex /\brg$/ with $ anchor might not match rg mid-path (e.g., /usr/bin/rg). Consider using just \brg\b (which you already use in the earlier test). Same for \bgrep$.

  2. Timeout mismatchhooks.json sets a 10-second timeout, but the npx fallback in the hook script has a 15-second spawnSync timeout. If the hook runner kills the process at 10s, the 15s inner timeout is never reached. You might want to align these (e.g., hook timeout at 20s, or npx timeout at 8s).

  3. Skills content duplication — The 7 skills in gitnexus-factory-plugin/skills/ appear to be near-copies of the Claude Code skills in .claude/skills/. Long-term this creates a maintenance burden. Consider whether the setup script could generate/symlink these from a single source of truth. Not a blocker for this PR, but worth noting.

  4. setup.ts and ai-context.ts changes — These look correct. The parallel installation to both .claude/skills/ and .factory/skills/ is straightforward. One thing to verify: does installFactoryHooks() handle the case where .factory/ doesn't exist yet? I see mkdirSync with recursive: true in the setup code, which should cover it.

  5. Plugin author attribution — The plugin.json lists you as the author, but the homepage/repository point to the main GitNexus repo. This seems appropriate for a first-party plugin contributed upstream.

  6. The shell hook (post-tool-use.sh) — Nice to have as a reference implementation, but make sure it's not also registered in hooks.json (it isn't — only the JS hook is). The shell version uses jq which may not be available everywhere. A note in the file header about this being an alternative would help.

Overall this is high-quality work with good attention to platform differences. The main actionable items are the regex fix and the timeout alignment.

@mrwogu mrwogu force-pushed the feat/factory-plugin branch from 2787491 to 8ee961a Compare March 9, 2026 08:27
@mrwogu

mrwogu commented Mar 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review, @reversTeam!

Rebased onto latest main and addressed the two actionable items:

Fixed:

  • Regex anchors — changed \brg$ / \bgrep$ to \brg\b / \bgrep\b so full paths like /usr/bin/rg are matched correctly. Applied the fix across all three hook variants (Factory plugin, Claude plugin, and core CLI hook).
  • Timeout alignment — reduced npx fallback timeout from 15s to 8s to fit within the 10s hook runner timeout with margin.

Acknowledged (follow-up):

  • Skills content duplication — agreed this should be generated from a single source. Will address separately to keep this PR focused.
  • Shell hook (post-tool-use.sh) is indeed a reference implementation only, not registered in hooks.json.

All tests passing locally (tsc --noEmit clean, 970+ tests green — remaining failures are pre-existing KuzuDB lock and parsing.test.ts fixture path issues from upstream).

mrwogu added 2 commits March 26, 2026 09:46
Port of gitnexus-claude-plugin adapted for Factory AI's plugin format:
- .factory-plugin/ manifest directory
- ${DROID_PLUGIN_ROOT} hook variable
- Root-level mcp.json (no dot prefix)
- PostToolUse hook (Factory PreToolUse doesn't support additionalContext)
- Execute tool name (Factory equivalent of Claude Code's Bash)
- Change \brg$ and \bgrep$ to \brg\b and \bgrep\b so full paths
  like /usr/bin/rg are matched correctly (all 3 hook variants)
- Reduce npx fallback timeout from 15s to 8s to fit within the
  10s hook runner timeout (Factory plugin)
@mrwogu mrwogu force-pushed the feat/factory-plugin branch from 08a6838 to ef12f98 Compare March 26, 2026 08:46
@github-actions

Copy link
Copy Markdown
Contributor

CI Report

All checks passed

Pipeline Status

Stage Status Details
✅ Typecheck success tsc --noEmit
✅ Tests success unit tests, 3 platforms
✅ E2E success gitnexus-web changes only

Test Results

Tests Passed Failed Skipped Duration
4321 4320 0 1 175s

✅ All 4320 tests passed

1 test(s) skipped — expand for details
  • buildTypeEnv > known limitations (documented skip tests) > Ruby block parameter: users.each { |user| } — closure param inference, different feature

Code Coverage

Tests

Metric Coverage Covered Base Delta Status
Statements 70.11% 10654/15196 71.04% 📉 -0.9 🔴 ██████████████░░░░░░
Branches 60.57% 7232/11939 61.63% 📉 -1.1 🔴 ████████████░░░░░░░░
Functions 73.78% 929/1259 74.45% 📉 -0.7 🔴 ██████████████░░░░░░
Lines 72.59% 9511/13101 73.38% 📉 -0.8 🔴 ██████████████░░░░░░

📋 View full run · Generated by CI

@magyargergo

Copy link
Copy Markdown
Collaborator

⚠️ Upcoming Prettier formatting — rebase instructions

PR #563 adds Prettier as the code formatter for the repo. When it merges, the bulk format commit will touch ~350 files (style-only: whitespace, quotes, trailing commas). Your branch will likely conflict.

After #563 merges, rebase your branch:

git fetch origin
git checkout <your-branch>
git rebase origin/main

# Conflicts will be formatting-only — accept your version:
git checkout --theirs .
git add .
git rebase --continue

# Then re-format your branch to match the new style:
npx prettier --write .
git add -A
git commit -m "style: apply prettier formatting"
git push --force-with-lease

New setup step: Run npm install at the repo root (not just in gitnexus/) to get prettier + activate the pre-commit hook. The hook auto-formats staged files on every commit going forward.

@magyargergo

Copy link
Copy Markdown
Collaborator

Please submit a new PR if this is still relevant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants